package github.sf.fw.tools.db.connector;


import github.sf.fw.tools.db.DSConnector;
import github.sf.fw.tools.db.DSProperty;

import java.io.IOException;

public class NebulaConnector implements DSConnector {
    //    private Session session;
    private DSProperty dsProperty;

    /**
     * 初始化nebula
     *
     * @param dsProperty
     */
    public NebulaConnector(DSProperty dsProperty) {
        this.dsProperty = dsProperty;
//        session = initNebulaSession(dsProperty);
    }

//    /**
//     * 初始化nebula方法
//     * @param dsProperty
//     * @return
//     */
//    private Session initNebulaSession(DSProperty dsProperty) {
//        NebulaPool pool = new NebulaPool();
//        NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig();
//        nebulaPoolConfig.setMaxConnSize(1000);
//        List<HostAddress> addresses = Arrays.asList(new HostAddress(dsProperty.getUrl(), Integer.parseInt(String.valueOf(dsProperty.getMeta().get("port")))));
//        Session session1;
//        try {
//            boolean init = pool.init(addresses, nebulaPoolConfig);
//            if (!init){
//                throw new RuntimeException("NebulaGraph 初始化错误 !");
//            }else {
//                session1 = pool.getSession(dsProperty.getUsername(), dsProperty.getPassword(), true);
//            }
//
//        } catch (UnknownHostException e) {
//            throw new RuntimeException("地址端口出错");
//        } catch (Exception e) {
//            throw new RuntimeException("nebula连接失败");
//        }
//
//        return session1;
//    }


    @Override
    public Object getConn() throws Exception {
        return null;
    }

    @Override
    public void close() throws IOException {

    }

    /**
     * 执行nebula的方法
     *
     * @param toString
     */
    public void dowrite(String toString) {
//        if (session==null){
//            throw new RuntimeException("nebula的session为空");
//        }
//        try {
//            session.execute(toString);
//        } catch (IOErrorException e) {
//            throw new RuntimeException(e);
//        }
    }
}
